﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AirlineBooking.Models.DTO
{
    public class DTOIntineraryStatus
    {
        static DTOIntineraryStatus(){
            using (AirLineDBModelEntities db = new AirLineDBModelEntities())
            {
                AirlineBooking.IntineraryStatu t = db.IntineraryStatus.FirstOrDefault(i => i.Status == "Booked");
                Booked = t != null ? new DTOIntineraryStatus(t) : null;
                t = db.IntineraryStatus.FirstOrDefault(i => i.Status == "Ready");
                Ready = t != null ? new DTOIntineraryStatus(t) : null;
                t = db.IntineraryStatus.FirstOrDefault(i => i.Status == "Cancelled");
                Cancelled = t != null ? new DTOIntineraryStatus(t) : null;
                t = db.IntineraryStatus.FirstOrDefault(i => i.Status == "Used");
                Used = t != null ? new DTOIntineraryStatus(t) : null;
            }
        }

        private DTOIntineraryStatus(int id, string value)
        {
            Id = id;
            Value = value;
        }

        private DTOIntineraryStatus(AirlineBooking.IntineraryStatu status)
            : this(status.Id, status.Status)
        {
        }
        public string Value { get; set; }
        public int Id { get; set; }
        public static readonly DTOIntineraryStatus Booked;
        public static readonly DTOIntineraryStatus Ready;
        public static readonly DTOIntineraryStatus Cancelled;
        public static readonly DTOIntineraryStatus Used;
    }
}